<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
    <meta name="author" content="Coderthemes">

    <link rel="stylesheet" href="/adminstatic/base/base.css"/>
    <script src="/adminstatic/base/baseCss.js"></script>

    <style type="text/css">
        html, body {
            background: #fff;
        }

        .layui-input-block {
            margin-left: 0;
        }
    </style>
</head>

<body class="fixed-left">

<!-- Begin page -->
<div id="wrapper" style="overflow: auto;">

    <div class="container">

        <div class="panel panel-default" style="box-shadow: none">
            <div class="panel-body">
                <form class="layui-form" action="">
                    <div id="inputForm" class="form-horizontal">
                        <input type="hidden" name="id" value="<%=id%>"/>
                        <div class="row" style="padding:0 20px">
                            <div class="form-group">
                                <div class="col-xs-12 col-md-4 ">
                                    <label for="title"><small class="notNullFlag">*</small> 菜单名称</label>
                                    <input class="form-control" type="text" id="title" name="title"
                                           value="<%=title%>" required>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-xs-12 col-md-4 ">
                                    <label for="url"> 菜单路径</label>
                                    <input class="form-control" type="text" id="url" name="url" value="<%=url%>"
                                           required>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-xs-12 col-md-4 ">
                                    <label for="icon"> 菜单icon</label>
                                    <input class="form-control" type="text" id="icon" name="icon"
                                           value="<%=icon%>"
                                           required>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-xs-12 col-md-4 ">
                                    <label for="icon"> 菜单序号</label>
                                    <input class="form-control" type="number" id="order" name="order"
                                           value="<%=orders%>"
                                           required maxlength="10">
                                </div>
                            </div>



<!--                            <% if(!id){%>-->
<!--                            <div class="form-group">-->
<!--                                <div class="col-xs-12 col-md-4 ">-->
<!--                                    <label for="status"> 关联菜单</label>-->
<!--                                    <div class="layui-form-item">-->
<!--                                        <div class="layui-input-block">-->
<!--                                            <label>-->
<!--                                                <select id='status' name="status" lay-verify="required"-->
<!--                                                        lay-filter="status">-->
<!--                                                    <option value="">不关联菜单</option>-->
<!--                                                    <#list parents as parent>-->
<!--                                                    <option value="${parent.id}">${parent.title}</option>-->
<!--                                                </#list>-->
<!--                                                </select>-->
<!--                                            </label>-->
<!--                                        </div>-->
<!--                                    </div>-->

<!--                                </div>-->
<!--                            </div>-->

<!--                            <div class="form-group">-->
<!--                                <div class="col-xs-12 col-md-4 ">-->
<!--                                    <label for="status"><small class="notNullFlag">*</small> 角色选择</label>-->

<!--                                    <div class="layui-form-item">-->
<!--                                        <div class="layui-input-block">-->
<!--                                            <div class="layui-input-block">-->
<!--                                                <#list adminList as admin>-->
<!--                                                <#if admin.roleType.name() == 'superRole'>-->
<!--                                                <input type="checkbox" name="${admin.id}" lay-filter="role"-->
<!--                                                       title="超级管理员">-->
<!--                                                <#else >-->
<!--                                                <input type="checkbox" name="${admin.id}" lay-filter="role"-->
<!--                                                       title="用户">-->
<!--                                            </#if>-->

<!--                                        </#list>-->
<!--                                    </div>-->
<!--                                </div>-->
<!--                            </div>-->

<!--                        </div>-->
<!--                    </div>-->

<!--                    <%}%>-->


                        </div>

                    </div>
                </form>
                <div id="actions">
                    <button type="button" class="layui-btn layui-btn-normal" id="submitBtn">保存</button>
                    <button type="button" class="layui-btn layui-btn-primary" onclick="closeIframe()">取消</button>
                </div>
            </div><!-- panel-body -->
        </div> <!-- panel -->

    </div> <!-- container -->

</div>
<!-- END wrapper -->

<script src="/adminstatic/base/base.js"></script>
<script type="text/javascript">

    $("#submitBtn").click(function () {
        var id = $("input[name='id']").val();
        var title = $("input[name='title']").val();
        var url = $("input[name='url']").val();
        var icon = $("input[name='icon']").val();
        var order = $("input[name='order']").val();
        console.log( id, title, order)
        if (!vaildeParam(title)) {
            layer.msg("菜单名称不能为空", {icon: 5});
            return;
        }
        if (!vaildeParam(order)) {
            layer.msg("菜单序号不能为空", {icon: 5});
            return;
        }

        var api = '/admin/admin_nav/update';
        var data = {
            "id": id,
            "title": title,
            "url": url,
            "icon": icon,
            "order": order,
        }

        postJSON(api, data, function (res) {
            cleanSuccess(res)
        })

    })
</script>
</body>
</html>